{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<COMObject Open>\n",
      "{}\n"
     ]
    },
    {
     "ename": "AttributeError",
     "evalue": "Add.items",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mAttributeError\u001B[0m                            Traceback (most recent call last)",
      "Input \u001B[1;32mIn [4]\u001B[0m, in \u001B[0;36m<cell line: 19>\u001B[1;34m()\u001B[0m\n\u001B[0;32m     16\u001B[0m pptInstance\u001B[38;5;241m.\u001B[39mVisible\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m\n\u001B[0;32m     18\u001B[0m pptPages\u001B[38;5;241m=\u001B[39mpptInstance\u001B[38;5;241m.\u001B[39mPresentations\u001B[38;5;241m.\u001B[39mAdd()\n\u001B[1;32m---> 19\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m key,value \u001B[38;5;129;01min\u001B[39;00m \u001B[43mpptPages\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mitems\u001B[49m():\n\u001B[0;32m     20\u001B[0m     pptSlider\u001B[38;5;241m=\u001B[39mpptPages\u001B[38;5;241m.\u001B[39mSlides\u001B[38;5;241m.\u001B[39mAdd(index\u001B[38;5;241m=\u001B[39mkey,Layout\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m12\u001B[39m)\n\u001B[0;32m     21\u001B[0m     excelInstance\u001B[38;5;241m.\u001B[39mRange(value)\u001B[38;5;241m.\u001B[39mCopy()\n",
      "File \u001B[1;32mD:\\ProgramData\\Miniconda3\\envs\\pythonoffice\\lib\\site-packages\\win32com\\client\\dynamic.py:639\u001B[0m, in \u001B[0;36mCDispatch.__getattr__\u001B[1;34m(self, attr)\u001B[0m\n\u001B[0;32m    636\u001B[0m     \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_get_good_object_(ret)\n\u001B[0;32m    638\u001B[0m \u001B[38;5;66;03m# no where else to look.\u001B[39;00m\n\u001B[1;32m--> 639\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mAttributeError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m%s\u001B[39;00m\u001B[38;5;124m.\u001B[39m\u001B[38;5;132;01m%s\u001B[39;00m\u001B[38;5;124m\"\u001B[39m \u001B[38;5;241m%\u001B[39m (\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_username_, attr))\n",
      "\u001B[1;31mAttributeError\u001B[0m: Add.items"
     ]
    }
   ],
   "source": [
    "import win32com.client\n",
    "\n",
    "excelInstance=win32com.client.Dispatch('Excel.Application')\n",
    "\n",
    "excelInstance.Visible=True\n",
    "sheets=excelInstance.Workbooks.Open(r\"C:\\Users\\Administrator\\Documents\\WeChat Files\\wxid_a9i1tbfx7ic222\\FileStorage\\File\\2022-03\\DisMeasureResult.xlsx\")\n",
    "print(sheets)\n",
    "sheetsArr={}\n",
    "for sheetName in sheets.Names:\n",
    "    index=sheetName.Index\n",
    "    name=sheetName.Name\n",
    "    sheetsArr[index]=name\n",
    "print(sheetsArr)\n",
    "\n",
    "pptInstance=win32com.client.Dispatch('PowerPoint.Application')\n",
    "pptInstance.Visible=True\n",
    "\n",
    "pptPages=pptInstance.Presentations.Add()\n",
    "for key,value in pptPages.items():\n",
    "    pptSlider=pptPages.Slides.Add(index=key,Layout=12)\n",
    "    excelInstance.Range(value).Copy()\n",
    "    #OLEObject linked\n",
    "    pptSlider.Shapes.PasteSpecial(DataType=10,Link=True)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "pycharm-c3e2e315",
   "language": "python",
   "display_name": "PyCharm (pythonoffice)"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}